<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>居中</title>
</head>
<body>
    <style>
        
        /* .box{
            height: 100px;
            width: 100px;
            background: #666;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-left: -50px;
            margin-top: -50px;
        } */
        /* .box{
            height: 100px;
            width: 100px;
            background: #666;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        } */
        /* html,body{
            height: 100%;
        }
        body{
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .box{
            height: 100px;
            width: 100px;
            background: #666;
        } */

        
    </style>
    <div class="box">

    </div>

</body>
</html>